﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DataMappers;
using ExaminationTT.Model;

namespace ConcreteMappersAndObjects.DomainObjects
{

    public struct SubscriptionKey 
    {
        private int _studentKey;
        private int _cunitKey;
        public SubscriptionKey(int studentKey, int cunitKey)
        {
            _studentKey = studentKey;
            _cunitKey = cunitKey;
        }
     
        public int StudentKey
        {
            get { return _studentKey; }
            set { _studentKey = value; }
        }

        public int CUnitKey
        {
            get { return _cunitKey; }
            set { _cunitKey = value; }
        }

    }
    public class Subscription : DomainObject<SubscriptionKey, Subscription> , ISubscription
    {
        private IValueHolder<int, Student> _student;
        private IValueHolder<int, CUnit> _cunit;


        public Subscription() : base()
        {
            _cunit = new ConcreteValueHolder<int, CUnit>();
            _student = new ConcreteValueHolder<int, Student>();
            
        }
        public Subscription(SubscriptionKey ID, 
            IValueHolder<int, Student> student,
            IValueHolder<int, CUnit> cunit)
             : base(ID)
        {
            _cunit = cunit;
            _student = student;

        }
        protected override Subscription Self()
        {
            return this;
        }

        #region ISubscriptionCUStudent Members

        public Student Student
        {
            get { return _student.Get(); }
            set { _student.Set(value); }
        }

        public CUnit CUnit
        {
            get { return _cunit.Get(); }
            set { _cunit.Set(value); }

        }

        #endregion



        #region ISubscription Members

        IStudent ISubscription.Student
        {
            get { return _student.Get(); }
        }

        ICUnit ISubscription.CUnit
        {
            get { return _cunit.Get(); }
        }

        #endregion
    }
}
